package routes

import (
	"cms/admin/controller"
	"cms/admin/middleware"
	"github.com/gin-gonic/gin"
)

func RegisterAdmin(app *gin.Engine)  {
	g := app.Group("admin")
	{
		g.GET("check_login", controller.Check)
		g.POST("login", controller.Login)

		g.Use(middleware.AuthMiddleware)
		{
			g.POST("edit_pwd", controller.EditPwd)
			g.POST("logout", controller.Logout)

			g.POST("upload/image", controller.Upload)

			g.GET("counter", controller.HomeCounter)

			g.GET("config", controller.GetConfig)
			g.POST("config", controller.SetConfig)
			g.POST("config/reload", controller.ReloadConfig)

			g.GET("charts", controller.ChartData)

			// 栏目
			g.GET("board_list", controller.GetBoardList)
			g.GET("board_types", controller.GetBoardTypes)

			g.POST("board", controller.CreateBoard)
			g.PUT("board/:id", controller.EditBoard)
			g.DELETE("board/:id", controller.DeleteBoard)

			// 管理员
			g.GET("managers", controller.GetAdminManagers)
		}
	}
}
